css: Start array allocation with a better size
authorAlexander Larsson <alexl@redhat.com>
Mon, 3 Dec 2012 13:29:40 +0000 (14:29 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 4 Dec 2012 19:16:44 +0000 (20:16 +0100)
All computed values will compute all normal properties at least, so
we might as well allocate these upfront, which leads to a lot less
reallocations.

gtk/gtkcsscomputedvalues.c

index f5f515a4a8c52e086d36a7221875fe6a22d4c00c..dea23bdf5e3ef50da9a0e2b4c63945bd034e415c 100644 (file)
@@ -179,7 +179,8 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
   gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
 
   if (values->values == NULL)
-    values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
+    values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
+                                          (GDestroyNotify)_gtk_css_value_unref);
   if (id >= values->values->len)
    g_ptr_array_set_size (values->values, id + 1);